/* @INLINE FILE moderation.bloc.js =============================================================
	* Mod functions
	* 
	* VAR
	* 
	* FUNC
	* applySearchResults
	*/
    
    function applySearchResults(data) {
        var v;
        var v2 = "&nbsp;";
        var count = 0;
        var option = data[0][0];
        var msg = data;
        if(searchType=='11'){
        	var strText = msg[1][0].replace(new RegExp( "\\n", "g" ),"<br>");
    		$('configfile').innerHTML = "<div style='width:1200px'>"+strText+"</div>";
    		return;
    	}
        //00>name>uid>name>uid>name>    etc... or for blocked ips 000>...
        $('searchoptions').selectedIndex = 0;
        $('searchtext').disabled=false;
        $('searchtext').focus();
        if (option.length == 2) {
            v = "<small><div style='padding:10px;font-weight:bold'>Search Results - page " + currPage + "</div></small><table width=100% cellpadding=4 style='padding:10px;margin-top:5px;border:0px solid #aaaaaa;'>";
            for (var i = 1; i < msg.length; i++) {
            	var identity = msg[i][0].split('&');
                var accountID='';
                msg[i][0]=_unescape(identity[0]);
                if(identity.length>1){
                	accountID=identity[1];
                }
                count ++ ;
                v += "<tr bgcolor='eeeeee'><td><small>" + (count + (currPage - 1) * 50) + ") <a href='javascript:fc_chat.getUserRec(" + msg[i][1] + ")'>" + msg[i][0] + "</a>&nbsp;&nbsp;"+(accountID==''?"":"("+_unescape(accountID)+")")+"</small></td></tr>";
            }
        } else if (option.length == 3) {
            v = "<small><div style='padding:10px;font-weight:bold'>Blocked IP's - page " + currPage + "</div></small><table width=100% cellpadding=4 style='padding:10px;margin-top:5px;border:0px solid #aaaaaa;'>";
            for (var i = 1; i < msg.length; i++) {
                //000>ip1>ip2>
                count ++ ;
                v += "<tr bgcolor='eeeeee'><td><small>" + (count + (currPage - 1) * 50) + ") " + msg[i][0] + "&nbsp;&nbsp;&nbsp;<div id='fc_ip" + count + "' style='display:inline'><a href='javascript:fc_chat.adminBlockIPByName(\"" + msg[i][0] + "\",0,0," + count + ")'>Unblock</a></div></small></td></tr>";
            }
        } else {
        	var _ttl = 'Words/Phrases to filter from chat text';
        	var _typ = 'M';
        	if(searchType=='10'){
        		_ttl = 'Words/Phrases to filter from screen names';
        		_typ='`';
        	}
            v = "<small><div style='padding:10px;font-weight:bold'>"+_ttl+" - page " + currPage + "</span></small><table width=100% cellpadding=4 style='padding:10px;margin-top:5px;border:0px solid #aaaaaa;'>";
            for (var i = 1; i < msg.length; i++) {
                //0000>ip1>ip2>
                count ++ ;
                var esc_msg=msg[i][0];
                msg[i][0] = msg[i][0].replace(/\\/g, '\\\\');
                msg[i][0] = msg[i][0].replace(/"/g, '\\"');
                msg[i][0] = msg[i][0].replace(/'/g, '&#39;');	
                v += "<tr bgcolor='eeeeee'><td><small>" + (count + (currPage - 1) * 50) + ") " + myUn(esc_msg, 1) + "&nbsp;&nbsp;&nbsp;<div id='fc_phrase" + count + "' style='display:inline'><a href='javascript:fc_chat.removeFromWordFilter(\"" + msg[i][0] + "\"," + count + ",\""+_typ+"\")'>Remove</a></div></small></td></tr>";
            }
        }
        if (count == 0) {
            v2 = "<small>No Results Found</small>";
        } else {
            if (option.charAt(0) == '1') {
                var prevPage = currPage - 1;
                v2 += "<a href='javascript:fc_chat.search(" + searchType + "," + prevPage + ")'><small>&laquo;&laquo; Previous Page</small></a>&nbsp;&nbsp;";
            }
            if (option.charAt(1) == '1') {
                var nextPage = currPage + 1;
                v2 += "<a href='javascript:fc_chat.search(" + searchType + "," + nextPage + ")'><small>Next Page &raquo;&raquo;</small></a>&nbsp;&nbsp;";
            }
        }
        v += "<tr bgcolor='eeeeee'><td>" + v2 + "</td></tr></table>";
        $('searchframe').innerHTML = v;
    };
    var listContains = function(list,s){
    	var listArray = list.split(",");
    	s = s + '';
    	for(var i = 0;i<listArray.length;i++){
    		if(listArray[i]==s){
    			return true;
    		}
    	};
    	return false;
    };
    function applyUserRec(data) {
        var v;
        var count = 0;
        var _accountType;
        var msg = data;
        //master account>uid>name>ip>title>acT>online>globalblock>privateblock>roomBlock>allowGlb>allowpriv>del   etc...
        var identity = msg[2].split('&');
        var accountID='';
        msg[2]=_unescape(identity[0]);
        if(identity.length>1){
        	accountID=identity[1];
        }
        if (msg[5] == '0') {
            _accountType = 'user';
        } else if (msg[5] == '1') {
            _accountType = 'moderator';
        } else {
            _accountType = 'administrator';
        }
        var userStatus='Offline';
        var userTitle=msg[4];
        userTitle = userTitle.replace(/%26/g, '&');
        userTitle = userTitle.replace(/%25/g, '%');
        userTitle = userTitle.replace(/'/g, '&#39;');
        if(msg[6]==='1'){
        	userStatus='Online';
        }
        var chk = [];
        chk[0] = (msg[7] == '1' ? 'checked': '');
        chk[1] = (msg[7] == '1' ? '': 'checked');
        chk[2] = (msg[8] == '1' ? 'checked': '');
        chk[3] = (msg[8] == '1' ? '': 'checked');
        chk[4] = (msg[5] == '1' ? 'checked': '');
        chk[5] = (msg[5] != '1' ? 'checked': '');
        chk[12] = (msg[5] == '2' ? 'checked': '');
        chk[13] = (msg[5] != '2' ? 'checked': '');
        var v2 = "";
        var blocked_rooms_list=msg[9];
        for (var ent in rooms) {
        	if(rooms.hasOwnProperty(ent)){
        		ent=ent-0;
	            var chk1 = '';
	            var chk2 = '';
	            if (listContains(blocked_rooms_list,ent)) {
	                chk1 = 'checked';
	            } else {
	                chk2 = 'checked';
	            }
	            v2 += "<tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Block chat in " + rooms[ent].nm + ":</small></td><td><small>Y</small><input id='arm" + ent + "1' type='radio' name='rm" + ent + "' value ='1' onclick='fc_chat.adminBlock(" + msg[1] + ",1,\"H\",\"" + ent + "\",\"" + rooms[ent].nm + "\")' " + chk1 + "></td><td><nobr><small>N</small><input id='arm" + ent + "0' type='radio' name='rm" + ent + "' value ='0' onclick='fc_chat.adminBlock(" + msg[1] + ",0,\"H\",\"" + ent + "\",\"" + rooms[ent].nm + "\")'" + chk2 + "></nobr></td></tr>";
	        }
        }
        v = "<small>" +
        		"<div style='padding:10px;font-weight:bold'>User Administration</div>" +
        	"</small>" +
        	"<table width=100% cellpadding=4 style='padding:10px;margin-top:5px;border:0px solid #aaaaaa;'>" +
        			"<tr bgcolor='eeeeee'><td colspan=3>" + "<small>User Name: <b>" + msg[2] + "</b>&nbsp;"+(accountID==''?"":"("+_unescape(accountID)+")")+"&nbsp;&nbsp;Last IP: <b>" + msg[3] + "</b></small></td></tr>" +
        			"<tr bgcolor='eeeeee'><td colspan=3><small>Account: <b><div id='accountType' style='display:inline'>" + _accountType + "</div></b></small></td></tr>" +
        			"<tr bgcolor='eeeeee'><td colspan=3><small>Status: (when record Loaded)&nbsp;<b><div id='userStatus' style='display:inline'>" + userStatus + "</div></b></small></td></tr>" +
        			
        			//Title
        			"<tr bgcolor='eeeeee'><td colspan=3><small>Title: </small><input id='ttlTxt' type='text' name='title' value ='"+userTitle+"'>&nbsp; <input type='button' id='ttlbtn' name='title button' value='Save' OnClick='fc_chat.adminSaveTitle(" + msg[1] + ")'><span style='display:none;margin-left:3px;color:green;font-style:italic' id='savingttl'>Saving...</span></td></tr>" +
        			
        			//Password
        			"<tr bgcolor='eeeeee'><td colspan=3><small>New Password: </small><br>" +
        			"<input id='pwrdtxt' type='password' name='password' value =''>&nbsp; <br><small>Confirm Password</small><br>" +
        			"<input id='pwrdtxt2' type='password' name='password' value =''>&nbsp;<input type='button' id='pwrdbtn' name='password button' value='Save' OnClick='fc_chat.adminSavePassword(" + msg[1] + ")'><span style='display:none;margin-left:3px;color:green;font-style:italic' id='savingpwrd'>Saving...</span></td></tr>" +
        			
        			"<tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Block chat in all rooms:</small></td><td><small>Y</small><input id='agbl1' type='radio' name='global' value ='1' onClick='fc_chat.adminBlock(" + msg[1] + ",1,\"F\",\"\",\"\")' " + chk[0] + "></td><td><nobr><small>N</small><input id='agbl0' type='radio' name='global' value='0' onClick='fc_chat.adminBlock(" + msg[1] + ",0,\"F\",\"\",\"\")' " + chk[1] + "></nobr></td></tr>" +
        			"<tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Block from private chat:</small></td><td><small>Y</small><input id='aprv1' type='radio' name='private' value ='1' onclick='fc_chat.adminBlock(" + msg[1] + ",1,\"G\",\"\",\"\")' " + chk[2] + "></td><td><nobr><small>N</small><input id='aprv0' type='radio' name='private' value ='0' onclick='fc_chat.adminBlock(" + msg[1] + ",0,\"G\",\"\",\"\")' " + chk[3] + "></nobr></td></tr>";
        v += v2;
        v += "<tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Releases Current Auto-Blocks:</small></td><td colspan=2><input type='button' id='autoblock' name='autoblock' value='Release' OnClick='fc_chat.adminReleaseAutoBlock(" + msg[1] + ")'></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Disconnect User:</small></td><td colspan=2><input type='button' id='aboot' name='boot' value ='Boot' OnClick='fc_chat.adminBoot(" + msg[1] + ")'></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Censor all messages: </small></td><td colspan=2><input id='del1' type='button' name='censor' value ='Censor' OnClick='fc_chat.adminDelAll(" + msg[1] + ")'></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Block IP for 30 min: (Admin Only)</small></td><td colspan=2><input type='button' id='tipblk' name='block' value ='Block' OnClick='fc_chat.adminBlockIP(" + msg[1] + ",0)'></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Block IP permanently: (Admin Only)</small></td><td colspan=2><input type='button' id='pipblk' name='block' value ='Block' OnClick='fc_chat.adminBlockIP(" + msg[1] + ",1)'></td></tr>" +
        		//Promote to admin
				"<tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Promote to Administrator: (Admin Only)</small></td><td><small>Y</small><input id='promo1a' type='radio' name='promoa' value ='1' " + chk[12] + " Onclick='fc_chat.adminGrantAdmin(" + msg[1] + ",1)'></td><td><nobr><small>N</small><input id='promo2a' type='radio' name='promoa' value ='0'" + chk[13] + " Onclick='fc_chat.adminGrantAdmin(" + msg[1] + ",0)'></nobr></td></tr>" +
        		
				"<tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Promote to Moderator: (Admin Only)</small></td><td><small>Y</small><input id='promo1' type='radio' name='promo' value ='1' " + chk[4] + " Onclick='fc_chat.adminGrantMod(" + msg[1] + ",1)'></td><td><nobr><small>N</small><input id='promo2' type='radio' name='promo' value ='0'" + chk[5] + " Onclick='fc_chat.adminGrantMod(" + msg[1] + ",0)'></nobr></td></tr>" +
        		"<tr bgcolor='eeeeee'><td colspan=3>&nbsp;</td></tr></table>";
        if (accountType == '2' && msg[5] == '1') {
            chk[6] = (msg[13] == '0' ? '': 'checked');
            chk[7] = (msg[13] == '0' ? 'checked': '');
            chk[8] = (msg[14] == '0' ? '': 'checked');
            chk[9] = (msg[14] == '0' ? 'checked': '');
            chk[10] = (msg[15] == '0' ? '': 'checked');
            chk[11] = (msg[15] == '0' ? 'checked': '');
            v += "<div id='modprivs' style='display:block'><br><small><div style='padding:10px;font-weight:bold'>Moderator Privileges</div></small><table width=100% style='padding:10px;margin-top:5px;border:0px solid #aaaaaa;'><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Allow Global Message Blocking:</small></td><td><small>Y</small><input  type='radio' id='allowGlb1' name='AllowGlb' value ='1' " + chk[6] + " Onclick='fc_chat.adminModPrivileges(" + msg[1] + ",1,1)'></td><td><nobr><small>N</small><input type='radio' id='allowGlb2' name='AllowGlb' value ='0' " + chk[7] + " Onclick='fc_chat.adminModPrivileges(" + msg[1] + ",1,0)'></nobr></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Allow Private Message Blocking:</small></td><td><small>Y</small><input  type='radio' id='allowpriv1' name='AllowPriv' value ='1' " + chk[8] + " Onclick='fc_chat.adminModPrivileges(" + msg[1] + ",2,1)'></td><td><nobr><small>N</small><input type='radio' id='allowpriv2' name='AllowPriv' value ='0' " + chk[9] + " Onclick='fc_chat.adminModPrivileges(" + msg[1] + ",2,0)'></nobr></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Allow Censor all Messages:</small></td><td><small>Y</small><input  type='radio' id='allowDel1' name='AllowDel' value ='1' " + chk[10] + " Onclick='fc_chat.adminModPrivileges(" + msg[1] + ",3,1)'></td><td><nobr><small>N</small><input type='radio' id='allowDel2' name='AllowDel' value ='0' " + chk[11] + " Onclick='fc_chat.adminModPrivileges(" + msg[1] + ",3,0)'></nobr></td></tr><tr bgcolor='eeeeee'><td colspan=3>&nbsp;</td></tr></table></div>";
        }
        $('userframe').innerHTML = v;
        if (accountType != '2') {
            $('tipblk').disabled = true;
            $('pipblk').disabled = true;
            $('promo1').disabled = true;
            $('promo2').disabled = true;
            $('promo1a').disabled = true;
            $('promo2a').disabled = true;
            $('ttlTxt').disabled = true;
            $('ttlbtn').disabled = true;
            $('pwrdbtn').disabled = true;
            if (msg[5] == '2') {
                $('agbl1').disabled = true;
                $('agbl0').disabled = true;
                $('aprv1').disabled = true;
                $('aprv0').disabled = true;
                $('aboot').disabled = true;
                $('del1').disabled = true;
                $('autoblock').disabled = true;
                for (var ent in rooms) {
                	if(rooms.hasOwnProperty(ent)){
                		ent=ent-0;
                		$('arm' + ent + '1').disabled = true;
                		$('arm' + ent + '0').disabled = true;
                	}
                }
            }
        } else {
        	if(msg[5] == '2'&&msg[1]!=_t.uid){
        		if(msg[0]!=_t.uid){
        			$('pwrdbtn').disabled = true;
        		}
        	}	
        	if ((msg[5] == '2'&&msg[0]!=_t.uid)||msg[1]==_t.uid) {
                $('promo1a').disabled = true;
                $('promo2a').disabled = true;
            }
            if (accountID==""&&(msg[2].substr(0,__(1).length)==__(1)||msg[2].indexOf('('+__(1))!=-1)){
                $('promo1').disabled = true;
                $('promo2').disabled = true;
                $('promo1a').disabled = true;
                $('promo2a').disabled = true;
            }
            if ((msg[5] == '2'&&msg[0]!=_t.uid)&&msg[1]!=_t.uid) {
	            $('tipblk').disabled = true;
	            $('pipblk').disabled = true;
	            $('promo1').disabled = true;
	            $('promo2').disabled = true;
	            $('promo1a').disabled = true;
	            $('promo2a').disabled = true;
	            $('ttlTxt').disabled = true;
	            $('ttlbtn').disabled = true;
	            $('pwrdbtn').disabled = true;
	            if (msg[5] == '2') {
	                $('agbl1').disabled = true;
	                $('agbl0').disabled = true;
	                $('aprv1').disabled = true;
	                $('aprv0').disabled = true;
	                $('aboot').disabled = true;
	                $('autoblock').disabled = true;
	                $('del1').disabled = true;
	                for (var ent in rooms) {
	                	if(rooms.hasOwnProperty(ent)){
	                		ent=ent-0;
	                		$('arm' + ent + '1').disabled = true;
	                		$('arm' + ent + '0').disabled = true;
	                	}
	                }
	            }
            }
        }
        if (msg[0]!=_t.uid) {
            $('promo1a').disabled = true;
            $('promo2a').disabled = true;
        }
        if(msg[5] == '2'){
        	$('promo1').disabled = true;
            $('promo2').disabled = true;
    	}
        if (accountID!=""||(msg[2].substr(0,__(1).length)==__(1)||msg[2].indexOf('('+__(1))!=-1)){
            $('pwrdbtn').disabled = true;
        }
        if (msg[10] == '0') {
            $('agbl1').disabled = true;
            $('agbl0').disabled = true;
        }
        if (msg[11] == '0') {
            $('aprv1').disabled = true;
            $('aprv0').disabled = true;
        }
        if (msg[12] == '0') {
            $('del1').disabled = true;
        }
    };
    this.search = function(sTyp, page) {
        if ( ! l && sTyp != 0) {
            if (accountType != '0' && ((sTyp != 6 && sTyp != 9 && sTyp != 10) || accountType == '2')) {
                l = true;
                var msg;
                var v;
                if (sTyp ==- 1) {
                    sTyp = 0;
                }
                searchType = sTyp;
                currPage = page;
                var sTypStr = String.fromCharCode((sTyp + 59));
                if(sTyp==10){
                	sTypStr = String.fromCharCode(95);
                }
                if (sTyp == 0 && page == 1) {
                    v = $('searchtext');
                    msg = v.value;
                    searchText = msg;
                    v.value = '';
                } else {
                    if (sTyp == 0) {
                        msg = searchText;
                    } else {
                        msg = '0';
                    }
                }
                msg = msg.replace(/&/g, '&amp;');
                msg = msg.replace(/</g, '&amp;lt;');
                msg = msg.replace(/>/g, '&amp;gt;');
                msg = msg.replace(/\\/g, '\\\\');
                if (msg.length > 0) {
                    if (msg.length < 50) {
                        req = '000' + (msg.length + 10);
                        if (page != 1) {
                            var pStr = page.toString();
                            req += sTypStr + pStr.length + pStr;
                            for (var i = 0; i < 8 - pStr.length; i ++ ) {
                                req += '0';
                            }
                        } else {
                            req += sTypStr + '110000000';
                        }
                        req += msg;
                        try {
                            connection.jsSendData(req);
                            png = new Date().getTime();
                        }
                        catch(err) {
                            showInfo('An Error Occurred. Please Refresh');
                        }
                    } else {
                        l = false;
                        showInfo('Search is too big (50 chars max).');
                        return;
                    }
                } else {
                    l = false;
                    showInfo('Please enter at least one character!');
                    return;
                }
                $('searchframe').innerHTML = "<center><div style='margin-top:85px'><small><b>Searching...Please Wait.</b></small></div></center>";
                fc_chat.lockAdmin();
            } else {
                l = false;
                $('searchframe').innerHTML = "<div style='margin-top:85px'><small><b>You do not have enough privileges to make this search.</b></small></div>";
            }
        }
    };
    this.getUserRec = function(uID) {
        if ( ! l && accountType != '0') {
            l = true;
            var uStr = uID.toString();
            req = '00010E' + uStr.length + uStr;
            for (var i = 0; i < 8 - uStr.length; i ++ ) {
                req += '0';
            }
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            $('userframe').innerHTML = "<center><div style='margin-top:85px'><small><b>Loading Record...Please Wait.</b></small></div></center>";
            fc_chat.lockAdmin();
        }
    };
    this.adminSaveTitle = function(uID) {
        if ( ! l && accountType == '2') {
            l = true;
            var title = $("ttlTxt").value;
            if(title==''){
            	var uStr = uID.toString();
	            req = '00010j' + uStr.length + uStr;
	            for (var i = 0; i < 8 - uStr.length; i ++ ) {
	                req += '0';
	            }
            }else{
	            title = title.replace(/%/g, '%25');
	            title = title.replace(/&/g, '%26amp;');
	            title = title.replace(/</g, '%26lt;');
	            title = title.replace(/>/g, '%26gt;');
	            title = title.replace(/\\/g, '\\\\');
	            if (checkLength(title) < 51) {
	                    req = '000' + (checkLength(title) + 10);
	            } else {
	                l = false;
	                showInfo('Title too big. 50 chars max.');
	                return false;
	            }
	            var uStr = uID.toString();
	            req += 'i' + uStr.length + uStr;
	            for (var i = 0; i < 8 - uStr.length; i ++ ) {
	                req += '0';
	            }
	            req += title;
            }
            $('savingttl').style.display = "inline";
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            fc_chat.lockAdmin();
        }
    };
    this.adminBlock = function(uID, n, v, v2, room) {
        if ( ! l) {
            if (accountType != '0') {
                l = true;
                var uStr = uID.toString();
                if (v2 != '') {
                    room = room.replace(/%/g, '%25');
                    room = room.replace(/&/g, '%26amp;');
                    room = room.replace(/</g, '%26lt;');
                    room = room.replace(/>/g, '%26gt;');
                    room = room.replace(/\\/g, '\\\\');
                    if (room.length > 0 && room.length < 300) {
                        if ((checkLength(room) + 17) < 100) {
                            req = '000' + (checkLength(room) + 17);
                        } else {
                            req = '00' + (checkLength(room) + 17);
                        }
                        req += v + n + zpad_left(v2,6) + uStr.length + uStr;
                        for (var i = 0; i < 8 - uStr.length; i ++ ) {
                            req += '0';
                        }
                        req += room;
                    } else {
                        l = false;
                        return false;
                    }
                } else {
                    req = '00011' + v + n + uStr.length + uStr;
                    for (var i = 0; i < 8 - uStr.length; i ++ ) {
                        req += '0';
                    }
                }
                try {
                    connection.jsSendData(req);
                    png = new Date().getTime();
                }
                catch(err) {
                    showInfo('An Error Occurred. Please Refresh');
                }
                fc_chat.lockAdmin();
            }
        } else {
            if (n == 0) {
                var q3 = v.charCodeAt(0);
                switch(q3) {
                    case 67: $('agbl1').checked = true;
                    break;
                    case 68: $('aprv1').checked = true;
                    break;
                    case 69: var q2 = v2-0;
                    for (var k = 0; k < 55; k ++ ) {
                        if (q2 == k) {
                            $('arm' + k + '1').checked = true;
                        }
                    }
                    break;
                    default: break;
                }
            }
            if (n == 1) {
                var q3 = v.charCodeAt(0);
                switch(q3) {
                    case 67: $('agbl0').checked = true;
                    break;
                    case 68: $('aprv0').checked = true;
                    break;
                    case 69: var q2 = v2-0;
                    for (var k = 0; k < 55; k ++ ) {
                        if (q2 == k) {
                            $('arm' + k + '0').checked = true;
                        }
                    }
                    break;
                    default: break;
                }
            }
        }
    };
    this.adminDelAll = function(uID) {
        if ( ! l && accountType != '0') {
            l = true;
            var uStr = uID.toString();
            if ((__(119).length + 11) < 100) {
                req = '000' + (__(119).length + 11);
            } else {
                req = '00' + (__(119).length + 11);
            }
            req += 'I1' + uStr.length + uStr;
            for (var i = 0; i < 8 - uStr.length; i ++ ) {
                req += '0';
            }
            req+=__(119);
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                l = false;
                showInfo('An Error Occurred. Please Refresh');
            }
            $('del1').disabled = true;
            setTimeout('fc_chat.adminRelease("del1")', 1000);
            fc_chat.lockAdmin();
        }
    };
    this.deleteMsg = function(page, index) {
        if ( ! l) {
            if (accountType != '0') {
                l = true;
                if ((__(119).length + 24) < 100) {
                    req = '000' + (__(119).length + 24);
                } else {
                    req = '00' + (__(119).length + 24);
                }
                var id;
                if (page == pgs[6] - 1) {
                    id = index;
                }else if (page!=0){
                	id = gmC - (uDC[1] + page * 50 - index);
                } else {
                    id = gmC - (uDC[1] + page * 50 - (uDC[1] - (dC[1]-index)));
                }
                var mStr = id.toString();
                req += 'J' + zpad_left(current_room,6) + mStr.length + mStr;
                for (var i = 0; i < 8 - mStr.length; i ++ ) {
                    req += '0';
                }
                req += '{{^^!^}}' + __(119);
                try {
                    connection.jsSendData(req);
                    png = new Date().getTime();
                }
                catch(err) {
                    showInfo('An Error Occurred. Please Refresh');
                }
                var prefix = (page == 0 ? '': 'p');
                $(prefix + 'censor' + index).innerHTML = "<font style='color:"+_chat_panels.font.color.censored_color+"'>**Censored**</font> ";
            }
        }
    };
    this.admin_clear_room = function(j) {
        if ( ! l) {
        	if (confirm("Are you sure you want to clear this room?"))
            { 
            if (accountType == '2') {
                l = true;
                var roomIndex = j-0;
                var room = rooms[roomIndex].nm;
                room = room.replace(/%/g, '%25');
                room = room.replace(/&/g, '%26amp;');
                room = room.replace(/</g, '%26lt;');
                room = room.replace(/>/g, '%26gt;');
                room = room.replace(/\\/g, '\\\\');
                if (room.length > 0 && room.length < 300) {
                    if ((checkLength(room) + 7) < 10) {
                        req = '0000' + (checkLength(room) + 7);
                    }else if ((checkLength(room) + 7) < 100) {
                            req = '000' + (checkLength(room) + 7);
                    } else {
                        req = '00' + (checkLength(room) + 7);
                    }
                } else {
                    l = false;
                    return false;
                }
                req += '^' + zpad_left(roomIndex,6) + room;
                try {
                    connection.jsSendData(req);
                    png = new Date().getTime();
                }
                catch(err) {
                    showInfo('An Error Occurred. Please Refresh');
                }
                fc_chat.lockAdmin();
            }
            }
        }
    };
    this.adminReleaseAutoBlock = function(uID) {
        if ( ! l && accountType != '0') {
            l = true;
            var uStr = uID.toString();
            req = '00010O' + uStr.length + uStr;
            for (var i = 0; i < 8 - uStr.length; i ++ ) {
                req += '0';
            }
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            $('autoblock').disabled = true;
            setTimeout('fc_chat.adminRelease("autoblock")', 1000);
            fc_chat.lockAdmin();
        }
    };
    this.adminGetConfig = function() {
        if ( ! l && accountType == '2') {    
            l = true;
            searchType='11';
            
            req = '00001b';
            $('configfile').innerHTML = " Loading...Please Wait.";
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            fc_chat.lockAdmin();
        }
    };
    this.adminReboot = function() {
        if ( ! l && accountType == '2') {
        	if (confirm("Are you sure you want to reboot the chat server?"))
            {      
	            l = true;
	            req = '00001a';
	            try {
	                connection.jsSendData(req);
	                png = new Date().getTime();
	            }
	            catch(err) {
	                showInfo('An Error Occurred. Please Refresh');
	            }
	            fc_chat.lockAdmin();
            }
        }
    };
    this.adminBoot = function(uID) {
        if ( ! l && accountType != '0') {
            l = true;
            var uStr = uID.toString();
            req = '00010N' + uStr.length + uStr;
            for (var i = 0; i < 8 - uStr.length; i ++ ) {
                req += '0';
            }
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            $('aboot').disabled = true;
            setTimeout('fc_chat.adminRelease("aboot")', 1000);
            fc_chat.lockAdmin();
        }
    };
    this.adminBlockIP = function(uID, blockType) {
        if ( ! l && accountType == '2') {
            l = true;
            var uStr = uID.toString();
            req = '00012K1' + blockType + uStr.length + uStr;
            for (var i = 0; i < 8 - uStr.length; i ++ ) {
                req += '0';
            }
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            var id = (blockType == 0 ? 'tipblk': 'pipblk');
            $(id).disabled = true;
            setTimeout('fc_chat.adminRelease("' + id + '")', 1000);
            fc_chat.lockAdmin();
        }
    };
    this.adminBlockIPByName = function(ip, block, blockType, count) {
        if ( ! l && accountType == '2') {
            l = true;
            req = '000' + (ip.length + 3) + 'L' + block + blockType + ip;
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            if (block == 0) {
                $('fc_ip' + count).innerHTML = "<font color=red>**Unblocked**</font>";
            }
            fc_chat.lockAdmin();
        }
    };
    this.addToWordFilter = function(iD) {
        if ( ! l && accountType == '2') {
            l = true;
            var phrase = $(iD).value;
            $(iD).value = '';
            phrase = phrase.replace(/%/g, '%25');
            phrase = phrase.replace(/&/g, '%26amp;');
            phrase = phrase.replace(/</g, '%26lt;');
            phrase = phrase.replace(/>/g, '%26gt;');
            phrase = phrase.replace(/\\/g, '\\\\');
            if (phrase.length == 0) {
            	l = false;
                showInfo('Please enter at least one character.');
                return false;
            }
            if (checkLength(phrase) < 51) {
                if ((checkLength(phrase) + 2) < 10) {
                    req = '0000' + (checkLength(phrase) + 2);
                } else {
                    req = '000' + (checkLength(phrase) + 2);
                }
            } else {
                l = false;
                showInfo('Phrase too big. About 50 chars max.');
                return false;
            }
            var fnc='M';
            if(iD=='filteruser'){
            	fnc = '`';
            }
            req += fnc + '1' + phrase;
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            fc_chat.lockAdmin();
        }
    };
    this.removeFromWordFilter = function(phrase, count, fnc) {
        if ( ! l && accountType == '2') {
            l = true;
            $('fc_phrase' + count).innerHTML = "<font color=red>**Removed**</red>";
            phrase = phrase.replace(/\\"/g, '"');
            phrase = phrase.replace(/%/g, '%25');
            phrase = phrase.replace(/&lt;/g, '%26lt;');
            phrase = phrase.replace(/&gt;/g, '%26gt;');
            phrase = phrase.replace(/&amp;/g, '%26amp;');
            phrase = phrase.replace(/\\/g, '\\\\');
            if (checkLength(phrase) < 51) {
                if ((checkLength(phrase) + 2) < 10) {
                    req = '0000' + (checkLength(phrase) + 2);
                } else {
                    req = '000' + (checkLength(phrase) + 2);
                }
            } else {
                l = false;
                return false;
            }
            req += fnc + '0' + phrase;
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            fc_chat.lockAdmin();
        }
    };
    this.adminBlockIPButton = function() {
        if ( ! l && accountType == '2') {
            if ($('ip1').value == '' || $('ip2').value == '' || $('ip3').value == '' || $('ip4').value == '') {
                showInfo('Invalid IP');
                return false;
            } else {
                var ip = $('ip1').value + '.' + $('ip2').value + '.' + $('ip3').value + '.' + $('ip4').value;
                fc_chat.adminBlockIPByName(ip, 1, 1);
                $('ip1').value = '';
                $('ip2').value = '';
                $('ip3').value = '';
                $('ip4').value = '';
                $('bip').disabled = true;
                setTimeout('fc_chat.adminRelease("bip")', 1000);
            }
            fc_chat.lockAdmin();
        }
        return false;
    };
    this.adminGrantAdmin = function(uID,grantType) {
        	setTimeout("fc_chat.adminGrantAdmin2("+uID+","+grantType+")",50)
    };
    this.adminGrantAdmin2 = function(uID, grantType) {
        if ( ! l) {
            if (accountType == '2') {
                l = true;
                var uStr = uID.toString();
                req = '00011l' + grantType + uStr.length + uStr;
                for (var i = 0; i < 8 - uStr.length; i ++ ) {
                    req += '0';
                }
                try {
                    connection.jsSendData(req);
                    png = new Date().getTime();
                }
                catch(err) {
                    showInfo('An Error Occurred. Please Refresh');
                }
                if (grantType == 1) {
                    $('accountType').innerHTML = "Administrator";
                    $('promo1a').checked = true;
                    $('promo2').checked = true;
                    $('promo1').disabled = true;
                    $('promo2').disabled = true;
                    if ($('modprivs') != null) {
                    	$('modprivs').style.display = 'none';
                    }
                } else {
                    $('accountType').innerHTML = "User";
                    $('promo1').disabled = false;
                    $('promo2').disabled = false;
                    if ($('modprivs') != null) {
                    	$('modprivs').style.display = 'none';	
                    }
                }
                fc_chat.lockAdmin();
            }
        } else {
            if (grantType == 1) {
                $('promo2a').checked = true;
            } else {
                $('promo1a').checked = true;
            }
        }
    };
    this.adminGrantMod = function(uID, grantType) {
    	setTimeout("fc_chat.adminGrantMod2("+uID+","+grantType+")",50)
    };
    this.adminGrantMod2 = function(uID, grantType) {
        if ( ! l) {
            if (accountType == '2') {
                l = true;
                var uStr = uID.toString();
                req = '00011P' + grantType + uStr.length + uStr;
                for (var i = 0; i < 8 - uStr.length; i ++ ) {
                    req += '0';
                }
                try {
                    connection.jsSendData(req);
                    png = new Date().getTime();
                }
                catch(err) {
                    showInfo('An Error Occurred. Please Refresh');
                }
                if (grantType == 1) {
                    $('accountType').innerHTML = "Moderator";
                    if ($('modprivs') == null) {
                        $('userframe').innerHTML += "<div id='modprivs' style='display:block'><br><small><div style='padding:10px;font-weight:bold'>Moderator Privileges</div></small><table width=100% style='padding:10px;margin-top:5px;border:0px solid #aaaaaa;'><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Allow Global Message Blocking:</small></td><td><small>Y</small><input  type='radio' id='allowGlb1' name='AllowGlb' value ='1' checked Onclick='fc_chat.adminModPrivileges(" + uID + ",1,1)'></td><td><nobr><small>N</small><input type='radio' id='allowGlb2' name='AllowGlb' value='0' Onclick='fc_chat.adminModPrivileges(" + uID + ",1,0)'></nobr></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Allow Private Message Blocking:</small></td><td><small>Y</small><input  type='radio' id='allowpriv1' name='AllowPriv' value ='1' checked Onclick='fc_chat.adminModPrivileges(" + uID + ",2,1)'></td><td><nobr><small>N</small><input type='radio' id='allowpriv2' name='AllowPriv' value ='0' Onclick='fc_chat.adminModPrivileges(" + uID + ",2,0)'></nobr></td></tr><tr bgcolor='eeeeee'><td bgcolor='eeeeee'><small>Allow Censor all Messages:</small></td><td><small>Y</small><input  type='radio' id='allowDel1' name='AllowDel' value ='1' checked Onclick='fc_chat.adminModPrivileges(" + uID + ",3,1)'></td><td><nobr><small>N</small><input type='radio' id='allowDel2' name='AllowDel' value ='0' Onclick='fc_chat.adminModPrivileges(" + uID + ",3,0)'></nobr></td></tr><tr bgcolor='eeeeee'><td colspan=3>&nbsp;</td></tr></table></div>";
                    } else {
                        $('modprivs').style.display = 'block';
                        $('allowGlb1').checked = true;
                        $('allowpriv1').checked = true;
                        $('allowDel1').checked = true;
                    }
                    $('promo1').checked = true;
                } else {
                    $('accountType').innerHTML = "User";
                    $('modprivs').style.display = 'none';
                }
                fc_chat.lockAdmin();
            }
        } else {
            if (grantType == 1) {
                $('promo2').checked = true;
            } else {
                $('promo1').checked = true;
            }
        }
    };
    this.adminModPrivileges = function(uID, grantType, grant) {
        if ( ! l) {
            if (accountType == '2') {
                l = true;
                var uStr = uID.toString();
                req = '00012Q' + grant + grantType + uStr.length + uStr;
                for (var i = 0; i < 8 - uStr.length; i ++ ) {
                    req += '0';
                }
                try {
                    connection.jsSendData(req);
                    png = new Date().getTime();
                }
                catch(err) {
                    showInfo('An Error Occurred. Please Refresh');
                }
                fc_chat.lockAdmin();
            }
        } else {
            if (grantType == 1) {
                if (grant == 1) {
                    $('allowGlb2').checked = true;
                } else {
                    $('allowGlb1').checked = true;
                }
            } else if (grantType == 2) {
                if (grant == 1) {
                    $('allowpriv2').checked = true;
                } else {
                    $('allowpriv1').checked = true;
                }
            } else {
                if (grant == 1) {
                    $('allowdel2').checked = true;
                } else {
                    $('allowdel1').checked = true;
                }
            }
        }
    };
    
    this.adminSavePassword = function(uID) {
    	//00042 | m | userIDlen (1 byte)| userid (8 bytes) | password (32 bytes)
        if ( ! l && accountType == '2') {
        	    l = true;
	            var pass1 = $('pwrdtxt').value;
	            var pass2 = $('pwrdtxt2').value;
	            $('pwrdtxt').value='';
	            $('pwrdtxt2').value='';
	            if(pass1!=pass2){
	            	l = false;
	            	showInfo('Passwords do not match.');
	            	return false;
	            }
	            var pass=false;
	            
	            if (pass1.length > 2 && pass1.length < 16) {
	                if (!reg.test(pass1)) {
	                	pass=true;
	                }
	            }
	            
	            if(!pass){
	            	l = false;
	            	showInfo('Room passwords must be between 3 and 15 characters. Letters, numbers, and underscores only.');
	            	return false;
	            }
	            var uStr = uID.toString();
	            req = '00042m' + uStr.length + uStr;
	            for (var i = 0; i < 8 - uStr.length; i ++ ) {
	                req += '0';
	            }
	            req+=jGo.MD5.hex_md5(pass1);
	            try {
	                connection.jsSendData(req);
	                png = new Date().getTime();
	            }
	            catch(err) {
	                showInfo('An Error Occurred. Please Refresh');
	            }
	            if(uID==_t.uid){
	            	setOwnPassword=jGo.MD5.hex_md5(pass1);
	            }
	            $('savingpwrd').style.display = "inline";
	            fc_chat.lockAdmin();
        }
    };
  
    this.adminUpdateConfigField = function(n) {
        if ( ! l && accountType == '2') {
        	var msg = "Reminder: If you update 'showTyping' or 'useAvatars' here, you must also update the corresponding variable in the client configuration file: FCChat/config/config.js. Refer to the product manual for more info.";
        	if(n=='3'){msg = "Warning: You should not change this setting unless you have been explicitly instructed to do so, as it may affect the operation of the chat. Do you want to continue?"};
        	if (n=='2'||n=='4'||n=='5'||confirm(msg))
            {
        		if (n=='2'||n=='1'||n=='0'||n=='5'){
            		l = true;
		            var field =n;
		            var value =EN($('configvalue'+n).selectedIndex)-1;
		            $('configvalue'+n).selectedIndex=0;
		            if(value==-1){
		            	l = false;
		            	showInfo('You must specify a value.');
		            	return;
		            }
		  
		            req= '00003';
		            req+= 'c' + field + value;
		            try {
		                connection.jsSendData(req);
		                png = new Date().getTime();
		            }
		            catch(err) {
		                showInfo('An Error Occurred. Please Refresh');
		            }
		            fc_chat.lockAdmin();
        		}
	            if(n=='3'){
	        		l = true;
		            var secret='';
	            	secret = $('configvalue3').value;
	                $('configvalue3').value = '';
	                if (secret.length > 512) {
	                    l = false;
	                    showInfo('Key is a bit too long. 512 chars max');
	                    return;
	                }
	                if (secret.length < 4) {
	                    l = false;
	                    showInfo('Key is too short. 4 chars min');
	                    return;
	                }
	                var initlen = secret.length+11;
		            req='';
		            if(initlen.length>100){
		            	req+='00'+initlen;
		            }else{
		            	req+='000'+initlen;
		            }
		            var secretlen=secret.length;
		            if(secret.length<10){
		            	secretlen='00'+secretlen;
		            }else if(secret.length<100){
		            	secretlen='0'+secretlen;
		            }
		            req+= 'c3000000'+secretlen + '' + secret;
		            try {
		                connection.jsSendData(req);
		                png = new Date().getTime();
		            }
		            catch(err) {
		                showInfo('An Error Occurred. Please Refresh');
		            }
		            fc_chat.lockAdmin();
	            }
	            if(n=='4'){
	        		l = true;
	            	var admin_name='';
	            	admin_name = $('adminname').value;
	                $('adminname').value = '';
	                if (admin_name.length > 512) {
	                    l = false;
	                    showInfo('Name is a bit too long. 512 chars max');
	                    return;
	                }
	                if (admin_name.length < 1) {
	                    l = false;
	                    showInfo('Please enter the name of the account you wish to use as an administrator.');
	                    return;
	                }
	            	var forumType=0;
	            	var int_accounts = ['','checkLength(room)','checkLength(room)','PHPbb','SMF','Drupal','joomla','MyBB'];
	            	var proxies = ["",
	            	               "../proxies/fcchat_wordpress_proxy.php",
	            	               "../proxies/fcchat_wordpress_proxy2.php",
	            	               "../proxies/fcchat_phpbb3_proxy.php",
	            	               "../proxies/fcchat_smf_proxy.php",
	            	               "../proxies/drupal.php",
	            	               "../proxies/joomla.php",
	            	               "../proxies/mybb.php"];
	            	forumType=EN($('configvalue'+n).selectedIndex);
		            $('configvalue'+n).selectedIndex=0;
		            if(forumType==0){
		            	l = false;
		            	showInfo('You must specify a value for CMS Type.');
		            	return;
		            }
		            jQ.post(proxies[forumType], {f:0},
		            		function(postResponse){
		            			var loginPackage = '';
		            		    var response=postResponse.split("<fcchatresponse>");
		            		    if(response.length>1){
		            		    	loginPackage = response[1];
		            		    }
		            		    if(loginPackage==''){  //offline
		                    		l = false;
		            				showInfo("Cannot continue because you are not currently logged in to " + int_accounts[forumType] + ". Plese log in to " + int_accounts[forumType] + " with the account you wish to use for fcchat administration.");
		            				return;
		            			}else{
			            			var data = loginPackage.split('&');
		        	    			var _account_id = data[0];
		        	    			var auth_token = data[1];
		        	    			var secret='';
		        	    			loginPackage=loginPackage.substr(_account_id.length+auth_token.length+2);
		        	    			var name_length = parseInt(loginPackage.substr(0,3),10);
		        	    			var _screen_name=loginPackage.substr(3,name_length);
		        	    			if(_screen_name.toLowerCase()!=admin_name.toLowerCase()){
		        	    				l = false;
		        	    				showInfo("The account name you provided does not match the " + int_accounts[forumType] + " account you are currently logged under.");
		        	            		return;
		        	    			}
		        	    			var namelen = checkLength(_screen_name);
		        	    			var accountlen = _account_id.length;
		        	    			var initlen = namelen+accountlen+11;
	        			            req='';
	        			            if(initlen.length>1000){
	        			            	req+='0'+initlen;
	        			            }else if(initlen.length>100){
	        			            	req+='00'+initlen;
	        			            }else{
	        			            	req+='000'+initlen;
	        			            }
	        			            if(namelen<10){
	        			            	namelen='00'+namelen;
	        			            }else if(namelen<100){
	        			            	namelen='0'+namelen;
	        			            }
	        			            if(_account_id.length<10){
	        			            	accountlen='0'+accountlen;
	        			            }
	        			            req+= 'c30' +  namelen + '' + accountlen + '000' + _screen_name + _account_id;
	        			            try {
	        			                connection.jsSendData(req);
	        			                png = new Date().getTime();
	        			            }
	        			            catch(err) {
	        			                showInfo('An Error Occurred. Please Refresh');
	        			            }
	        			            fc_chat.lockAdmin();
		            			}
		            		},"html"
		            	).error(function(e) { 
		            		l = false;
		            		showInfo("Cannot continue because you are not currently logged in to " + int_accounts[forumType] + ". Plese log in to " + int_accounts[forumType] + " with the account you wish to use for fcchat administration.");
		            		return; 
		            	})
	            }
            }
        }
    };
    this.adminSetConsoleMode = function() {
        if ( ! l && accountType == '2') {
            l = true;
            var c_mode = $('console_mode').value;
            var chatID = $('chat_id').value;
            if(chatID==''){chatID='0000000000000000'};
            req = '00018d' + c_mode + chatID;
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }
            catch(err) {
                showInfo('An Error Occurred. Please Refresh');
            }
            fc_chat.lockAdmin();
        }
    };
    this.admin_delete_room = function(j){   
    	if(!l){
    		if (confirm("Are you sure you want to delete this room?"))
            {      
	    		l=true;
	    		req='00007k'+ zpad_left(j,6);
		        try {
		            connection.jsSendData(req);
		            png = new Date().getTime();
		        }catch(err) {
		            chatroom_panel_inner[_i] = _er;
		        }
		        fc_chat.lockAdmin();
            }
    	}
    };
    this.admin_create_edit_room = function(edit,j){
    	if(!l){
	    	// DETERMINE THE POSITION OF THE ROOM
	    	var roompos=0;
	    	if(edit==0){
		    	for (var ent in rooms) {
		        	if(rooms.hasOwnProperty(ent)){
		        		roompos++;
		        	}
		        }
	    	}else{
	    		var index=first_room_index;
	    		 if(index!=j){
					  while(true){
						  roompos++;
						  ind=rooms[index].next;
					  	  if(ind==j){
					  		  break;
					  	  }
					  	  index=ind;
					  }
	    		 }
	    	}
	    	
	    	// SET UP ROOM DATA
	    	var edit_room_panel=main_panel.edit_room_panel;
	    	var roomname=(edit==1?rooms[j].nm:'');
	    	roomname = roomname.replace(/'/g, '&#39;');
	    	var roomdesc=(edit==1?rooms[j].dsc:'');
	    	roomdesc = roomdesc.replace(/'/g, "&#39;");
	    	var chk1='checked';
	    	var chk2='';
	    	if(edit==1 && rooms[j].v){
	    		chk2='checked';
	    		chk1='';
	    	}
	    	if(edit!=1){
	    		j=0;
	    	}
	
	    	//BUILD THE CONTENT
	       	var cont = "<div id='fc_passbox'><table cellpadding='3' style='padding:5px;margin-left:10px;margin-right:15px;margin-top:20px'><tr><td ><div><font id='fc_passtxt' style='"+edit_room_panel.font.title_css+"'>" + (edit==1?"Edit":"Create") + " Room.</font><br><br></div></td></tr>" +
	       			"<tr><td><div><input id='fc_roomname' value='"+roomname+"' type=text name=name style='width:240px;"+edit_room_panel.textfield_css+"' maxlength='50'>&nbsp;<span style='"+edit_room_panel.font.textfield_description_css+"'>Room Name</span><br><br></div></td></tr>" +
	       			"<tr><td><div><input id='fc_roomdesc' value='"+roomdesc+"' type=text name=desc style='width:300px;"+edit_room_panel.textfield_css+"' maxlength='300'>&nbsp;<span style='"+edit_room_panel.font.textfield_description_css+"'>Room Description</span><br><br></div></td></tr>" +
	       			"<tr><td><div><input id='fc_roompass' type=password name=password style='width:120px;"+edit_room_panel.textfield_css+"' maxlength='15'>&nbsp;<span style='"+edit_room_panel.font.textfield_description_css+"'>Room Password</span><br><font id='fc_pswrdtxt' style='"+edit_room_panel.font.smalltext_css+"'>Leave blank if no password.</font><br><br></div></td></tr>" +
	       			(j!=first_room_index?
	       					"<tr><td><div><input id='fc_roomindex' onKeyPress='return numbersonly(this, event)' type=text name=index style='width:120px;"+edit_room_panel.textfield_css+"' value='"+roompos+"' maxlength='2'>&nbsp;<span style='"+edit_room_panel.font.textfield_description_css+"'>Room Index</span><br><font id='fc_pswrdtxt' style='"+edit_room_panel.font.smalltext_css+"'>Position below first room: 1,2,3,etc.</font><br><br></div></td></tr>"
	       			:"") +
	       			"<tr><td><div id='fc_allow_video' style='width:300px;height:20px;"+edit_room_panel.font.textfield_description_css+"'>Allow Video:&nbsp;&nbsp;&nbsp;&nbsp;" +
					"<INPUT TYPE=radio  id='fc_allowvideo1' name='DTM' " + chk1 + " VALUE='1'>yes&nbsp;&nbsp;" +
					"<INPUT TYPE=radio  id='fc_allowvideo2' name='DTM' " + chk2 + " VALUE='0'>no" +
					"</div></td></tr><tr><td>" +
	       			"<br><input type=button id='fc_renter' name='Submit' value='"+(edit==1?'Edit':'Create')+"' style='font-size:7pt' onclick='fc_chat.admin_validate_room(\""+j+"\")'>&nbsp;<input type=button id='fc_rexit' name='Exit' value='Cancel' onclick='fc_chat.tgl_info_panel()' style='font-size:7pt'></nobr><br><br></div></td></tr></table></div>";
	        info_panel[_i]=cont;
    	}
    };
    this.admin_validate_room = function(j){
    	if(!l){
	    	l = true;
	    	$('fc_passtxt')[_i] = "Please wait.";
	    	$('fc_renter').disabled = true;
	        $('fc_rexit').disabled = true;
	        var roompass = ($('fc_roompass')?$('fc_roompass').value:'');
	        if($('fc_roompass')){	
	        	$('fc_roompass').value = '';
	        }
	        var pass = false;
	        if(roompass==''){
	        	pass = true;
	        }
	        if (roompass.length > 2 && roompass.length < 16) {
                if (!reg.test(roompass)) {
                	pass=true;
                }
	        }
            if(!pass){
            	l = false;
            	$('fc_passtxt')[_i] = 'Room passwords must be between 3 and 15 characters. Letters, numbers, and underscores only.';
            	$('fc_renter').disabled = false;
    	        $('fc_rexit').disabled = false;
            	return false;
            }
        	var roomname=$('fc_roomname').value;
        	$('fc_roomname').value = '';
        	if (roomname.length > 0 && roomname.length <= 50) {
        		roomname = roomname.replace(/%/g, '%25');
	            roomname = roomname.replace(/&/g, '%26amp;');
	            roomname = roomname.replace(/</g, '%26lt;');
	            roomname = roomname.replace(/>/g, '%26gt;');
	            roomname = roomname.replace(/\\/g, '\\\\');
            }else{
            	$('fc_passtxt')[_i] = "Room names must be between 1 and 50 chars.";
            	l = false;
            	$('fc_renter').disabled = false;
    	        $('fc_rexit').disabled = false;
            	return false;
            }
        	var roomdesc=$('fc_roomdesc').value;
        	$('fc_roomdesc').value = '';
        	if (roomdesc.length <= 300) {
        		roomdesc = roomdesc.replace(/%/g, '%25');
	            roomdesc = roomdesc.replace(/&/g, '%26amp;');
	            roomdesc = roomdesc.replace(/</g, '%26lt;');
	            roomdesc = roomdesc.replace(/>/g, '%26gt;');
	            roomdesc = roomdesc.replace(/\\/g, '\\\\');
            }else{
            	$('fc_passtxt')[_i] = "Room descriptions must be less than 300 chars.";
            	l = false;
            	$('fc_renter').disabled = false;
    	        $('fc_rexit').disabled = false;
            	return;
            }
            var roomindex=($('fc_roomindex')?$('fc_roomindex').value:0);
            roomindex=Math.min(EN(roomindex),199);
        	var allowvideo=($('fc_allowvideo1').checked?'0':'1');
        	//msg length | 93 | roomIndex | roomPosition | video chat disabled [1 byte] | room name length [2 bytes] | room name | room description length [3 bytes] | room description | password length [2 bytes] | password | 
        	var len = 21 + checkLength(roomname) + checkLength(roomdesc) + checkLength(roompass);
        	req='000'+len;
        	if(len>=100){
        		req='00'+len;
        	}
        	if(len>=1000){
        		req='0'+len;
        	}
        	req+=']' + zpad_left(j,6) + zpad_left(roomindex,6) + allowvideo;
        	if(checkLength(roomname)>=10){
        		req+=''+checkLength(roomname);
        	}else{
        		req+='0'+checkLength(roomname);
        	}
        	req+=roomname;
        	if(checkLength(roomdesc)>=100){
        		req+=''+checkLength(roomdesc);
        	}else if(checkLength(roomdesc)>=10){
            		req+='0'+checkLength(roomdesc);
            }else{
        		req+='00'+checkLength(roomdesc);
        	}
        	req+=roomdesc;
        	if(checkLength(roompass)>=10){
        		req+=''+checkLength(roompass);
        	}else{
        		req+='0'+checkLength(roompass);
        	}
        	req+=roompass;
            try {
                connection.jsSendData(req);
                png = new Date().getTime();
            }catch(err) {
                chatroom_panel_inner[_i] = _er;
            }
            curr_state[7]='1';
            fc_chat.lockAdmin();
    	}
    };
    this.adminRelease = function(divID) {
        $(divID).disabled = false;
    };
    this.lockAdmin = function(){
    	$('leftframecover').style.display = "block";
    	$('bip').disabled = true;
        $('reboot').disabled = true;
        $('getconfig').disabled = true;
        $('setconfigvalue0').disabled = true;
        $('setconfigvalue1').disabled = true;
        $('setconfigvalue2').disabled = true;
        $('configvalue3').disabled = true;
        $('setconfigvalue4').disabled = true;
        $('setconfigvalue5').disabled = true;
        $('searchtext').disabled = true;
        $('searchoptions').disabled = true;
        $('filterchat').disabled = true;
        $('filteruser').disabled = true;
        
        unlockAdmin=true;
    };
    
    //moderation.bloc.js =============================================================@END FILE*/